package Z02IOStream.W08shujuStream;


import java.io.*;

public class TestWriterAndReading {}

class Test{
    public static void main(String[] args) {
         writer();
         read();
    }

    private static void writer() {
        File f = new File("c:LOL.txt");

        try(
             FileOutputStream fos = new FileOutputStream(f);
             DataOutputStream dos = new DataOutputStream(fos);) {
            dos.writeBoolean(true);
            dos.writeInt(300);
            dos.writeUTF("123 Thid is w");
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    private static void read() {
        File f = new File("C:/LOL.txt");
        try (
                FileInputStream fis = new FileInputStream(f);
                DataInputStream dis = new DataInputStream(fis);
                ){
            boolean b = dis.readBoolean();
            int i = dis.readInt();
            String str = dis.readUTF();

            System.out.println("读取到的布尔值：" + b);
            System.out.println("读取到的整数：" + i);
            System.out.println("读取到的字符串：" + str);

        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
